﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFEdit.Views
{
    /// <summary>
    /// Interaction logic for TypeSelector.xaml
    /// Bindings:
    /// InputLabel1, InputLabel2, InputLabel3, WindowTitle, Items
    /// </summary>
    public partial class Selector : Window
    {
        public Selector()
        {
            InitializeComponent();
            OKButton.IsEnabled = (SelectedIndex >= 0);
        }

        public int SelectedIndex
        {
            get { return SelectorItems.SelectedIndex; }
            set { SelectorItems.SelectedIndex = value; }
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        public bool ShowInput1
        {
            get { return InputBoxLabel1.Visibility == Visibility.Visible; }
            set
            {
                InputBoxLabel1.Visibility = value ? Visibility.Visible : Visibility.Hidden;
                InputTextBox1.Visibility = value ? Visibility.Visible : Visibility.Hidden;
            }
        }
        public bool ShowInput2
        {
            get { return InputBoxLabel2.Visibility == Visibility.Visible; }
            set
            {
                InputBoxLabel2.Visibility = value ? Visibility.Visible : Visibility.Hidden;
                InputTextBox2.Visibility = value ? Visibility.Visible : Visibility.Hidden;
            }
        }
        public bool ShowInput3
        {
            get { return InputBoxLabel3.Visibility == Visibility.Visible; }
            set
            {
                InputBoxLabel3.Visibility = value ? Visibility.Visible : Visibility.Hidden;
                InputTextBox3.Visibility = value ? Visibility.Visible : Visibility.Hidden;
            }
        }

		public ListBox ListBoxControl
		{
			get { return SelectorItems; }
		}

        public string InputText1
        {
            set { InputTextBox1.Text = value; }
            get { return InputTextBox1.Text; }
        }
        public string InputText2
        {
            set { InputTextBox2.Text = value; }
            get { return InputTextBox2.Text; }
        }
        public string InputText3
        {
            set { InputTextBox2.Text = value; }
            get { return InputTextBox2.Text; }
        }

        public event TextChangedEventHandler InputText1Changed
        {
            add { InputTextBox1.TextChanged += value; }
            remove { InputTextBox1.TextChanged -= value; }
        }
        public event TextChangedEventHandler InputText2Changed
        {
            add { InputTextBox2.TextChanged += value; }
            remove { InputTextBox2.TextChanged -= value; }
        }
        public event TextChangedEventHandler InputText3Changed
        {
            add { InputTextBox3.TextChanged += value; }
            remove { InputTextBox3.TextChanged -= value; }
        }

        private void SelectorItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            OKButton.IsEnabled = true;
        }

		public bool IsOKEnabled
		{
			get { return OKButton.IsEnabled; }
			set { OKButton.IsEnabled = value; }
		}
    }
}
